import Vue from "vue";
import Vuex from "vuex";
import Cookie from "cookie_js";

import { Login } from "@/api/login";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    isCollapse: JSON.parse(sessionStorage.getItem("isCollapse")) || false,
    // isCollapse : JSON.parse(Cookie.get("isCollapse") ) ||  false ,
    count: 10
  },
  getters: {

  },
  mutations: { // 没有回调
    SET_COLLAPSE(state) {
      state.isCollapse = !state.isCollapse;
      sessionStorage.setItem("isCollapse", JSON.stringify(state.isCollapse));
      // Cookie.set("isCollapse",JSON.stringify( state.isCollapse)) ;
    }
  },
  actions: { // 可以回调

    login(content, data) {
      return new Promise((resolve, reject) => {
        // 接口
        Login(data).then((rep) => {
          return resolve(rep);
        }).catch(err => {
          return reject();
        })
      })
    
    }
  },
  modules: {}
});


// cookie.set()  get() ;